<?php
namespace Biz\model\activity;

use Doraemon\pockets\datebase\BaseDbModel;

class NewCommerExclusive extends BaseDbModel
{

	const _CONFIG_FILE_ = 'db_shop';

	const _CONFIG_SELECT_ = 'db_activity';

	const _DATABASE_ = 'shop_activity';

	const _TABLE_NAME = 'newcommer_exclusive';

	const STATUS_NORMAL = 1;

	const STATUS_NO_PRICE = 2; // 中间态 未更新活动价状态

	const STATUS_DELETE = 9;


	public static function getNotOverList($goodsIds)
	{
		$infos = self::select('*', [
			'goods_id' => $goodsIds,
			'end_time[>]' => date('Y-m-d H:i:s'),
			'status' => self::STATUS_NORMAL
		]);
		$rst = [];
		foreach ($infos as $info) {
			$rst[$info['goods_id']][] = $info;
		}

		return $rst;
	}

    public static function getActiveList($limit)
    {
        $list = self::select('*', [
            'end_time[>]' => date('Y-m-d H:i:s'),
            'start_time[<]' => date('Y-m-d H:i:s'),
            'status' => self::STATUS_NORMAL,
            'LIMIT' => $limit,
            'ORDER' => [
                'add_time' => 'DESC'
            ],
        ]);
        return $list;
    }
    public static function getActiveCount()
    {
        $list = self::count('*', [
            'end_time[>]' => date('Y-m-d H:i:s'),
            'start_time[<]' => date('Y-m-d H:i:s'),
            'status' => self::STATUS_NORMAL,
        ]);
        return $list;
    }

}